import java.util.Map;
import java.util.Scanner;
import java.util.HashMap;
public class ManagementSystem {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        HashMap<String, String> user= new HashMap<String , String>();
        int input = 0;
        do{
            menu();
            System.out.println("请输入：");
            input = sc.nextInt();
            switch (input){
                case 1:
                    login(user);
                    break;
                case 2:
                    register(user);
                    break;
                case 3:
                    show(user);
                    break;
                case 0:
                    System.out.println("退出管理系统！");
                    break;
                default:
                    System.out.println("输入错误！");
                    break;
            }
        }while(input!=0);
    }
    public static void menu(){
        System.out.println("--------------xx管理系统---------------");
        System.out.println("1.登录功能（login）");
        System.out.println("2.注册功能（register）");
        System.out.println("3.查看（show）");
        System.out.println("0.退出（exit）");
        System.out.println("--------------xx管理系统---------------");
    }
    public static void login(HashMap<String,String> user){
        //show(user);
        Scanner sc = new Scanner(System.in);
        System.out.println("输入你的用户名：");
        String userName = sc.nextLine();
        System.out.println("输入你的密码：");
        String password = sc.nextLine();
        if(user.get(userName).equals(password)){
            System.out.println("登入成功！");
        }
        else{
            System.out.println("登入失败！");
        }

    }
    public static void register(HashMap<String,String> user){
        Scanner sc = new Scanner(System.in);
        System.out.println("输入你的用户名：");
        String userName = sc.nextLine();
        System.out.println("输入你的密码：");
        String password = sc.nextLine();
        user.put(userName,password);
    }
    public static void show(HashMap<String,String> user){
        for(Map.Entry<String,String> entry:user.entrySet()){
            System.out.println("用户名："+entry.getKey()+",密码："+entry.getValue());
        }

    }
}
